cmake_minimum_required(VERSION 3.10)
project(test-ji-api)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INSTALL_PREFIX "/usr/local/ev_sdk")
set(CMAKE_CXX_FLAGS "-O3")
set(CMAKE_BUILD_TYPE "Release")

set(BMNNSDK /opt/sophon)

set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_ASM_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)

set(BM_LIBS bmlib bmrt bmcv yuv)
set(OPENCV_LIBS opencv_imgproc opencv_core opencv_highgui opencv_imgcodecs opencv_videoio)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:/usr/local/ev_sdk/lib")

include_directories(${CMAKE_SOURCE_DIR}/../3rd/jsoncpp_simple/include)
add_subdirectory(${CMAKE_SOURCE_DIR}/../3rd/jsoncpp_simple json.out)

include_directories(${BMNNSDK}/sophon-opencv-latest/include/opencv4/
                    ${BMNNSDK}/sophon-ffmpeg-latest/include
                    ${CMAKE_CURRENT_SOURCE_DIR}
                    ${BMNNSDK}/libsophon-0.4.9/include
                    /usr/local/ev_sdk/include
        )

link_directories(${BMNNSDK}/sophon-opencv-latest/lib
        ${BMNNSDK}/sophon-ffmpeg-latest/lib
        ${BMNNSDK}/libsophon-0.4.9/lib
        )

add_executable(${PROJECT_NAME}
        ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Algo.cpp
        )

target_link_libraries(${PROJECT_NAME}
                        ${OPENCV_LIBS}
                        ${BM_LIBS}
                        glog
                        pthread
                        /usr/local/ev_sdk/lib/libji.so
                        jsoncpp
                        -lavcodec
                        -lavformat
                        -lavutil
        )

install(TARGETS ${PROJECT_NAME} DESTINATION bin)

